package com.qa.dom.controller;


import com.baomidou.mybatisplus.plugins.Page;
import com.qa.dom.dto.MyMessageDto;
import com.qa.dom.entity.Returnplay;
import com.qa.dom.entity.Usertable;
import com.qa.dom.service.IQuestionanswerService;
import com.qa.dom.service.IUsertableService;
import com.qa.dom.util.JsonResult;
import com.qa.dom.util.baseAction;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 问答管理
 * @author z77z
 * @since 2017-12-25
 */
@Api(description = "问答管理",tags = {"QUESTIONANSWER"})
@RestController
@RequestMapping("/questionanswer")
    public class QuestionAnswerController extends baseAction {
        @Resource
        private IQuestionanswerService questionanswerService;

        @Resource
        private IUsertableService usertableService;

        /*-------------------------------- 我的消息 ----------------------------------*/
        @GetMapping("/queryMyMessage")
        @ApiOperation(value = "我的消息",notes = "我的消息",httpMethod = "GET")
        public JsonResult queryMyMessage(@ApiParam("当前页") @RequestParam("page") Integer page, @ApiParam("每页大小") @RequestParam("limit") Integer limit){
            Usertable usertable = getCurrentUser();
            Page<MyMessageDto> page1 = new Page<>(page, limit);
            System.out.println(page1);
            usertable = usertableService.selectById(1);
            Page<MyMessageDto> s = questionanswerService.queryMyMessage(page1,usertable);
            return renderSuccess(0,"", s.getTotal(),  s.getRecords());
        }

}





